home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 05.zip
/
BS1 part 5
/
Images .adf
/
Developers_Den
/
negative.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-08
|
3KB
|
115 lines
/*
* negative.c - Does a simple negative in Imagemaster
*/
#include <stdio.h>
struct jackinbuff
{
unsigned char *red;
unsigned char *green;
unsigned char *blue;
unsigned char *mask;
unsigned short x;
unsigned short y;
};
struct jackina
{
struct jackinbuff *primary;
struct jackinbuff *secondary;
struct jackinbuff *undo;
struct jackinbuff *blend;
struct jackinbuff *brush;
unsigned char *mask;
char jack[4];
};
static struct jackina *jackins;
static struct jackinbuff *primary_jack;
static struct jackinbuff *secondary_jack;
static struct jackinbuff *undo_jack;
static struct jackinbuff *blend_jack;
static struct jackinbuff *brush_jack;
main(argc,argv)
int argc;
char *argv[];
{
unsigned int tpoint,x,y,xw,yw,offset,yoffset;
unsigned char rr,gg,bb;
unsigned char *rbu;
unsigned char *gbu;
unsigned char *bbu;
printf("NEGATIVE <pointer to IM jackin structure>\n");
printf("A simple Imagemaster Public Interface operation.\n");
if (argc <= 1)
{
printf("NEGATIVE : No argument supplied!\n");
return(1);
}
else
{
sscanf(argv[1],"%X",&tpoint);
}
if (tpoint == 0)
{
printf("NEGATIVE : Argument is ZERO!\n");
return(1);
}
jackins = (struct jackina *)tpoint;
if (jackins->jack[0] != 'J' ||
jackins->jack[1] != 'A' ||
jackins->jack[2] != 'C' ||
jackins->jack[3] != 'K' )
{
printf("NEGATIVE : Problem in information passed from Imagemaster!\n");
return(1);
}
if (jackins->primary == NULL)
{
printf("NEGATIVE : Primary buffer is NULL!\n");
return(1);
}
xw = jackins->primary->x;
yw = jackins->primary->y;
if (xw == 0 || yw == 0)
{
printf("NEGATIVE : Primary buffer is Empty!\n");
return(1);
}
rbu = jackins->primary->red;
gbu = jackins->primary->green;
bbu = jackins->primary->blue;
if (rbu == NULL || gbu == NULL || bbu == NULL)
{
printf("NEGATIVE : Primary buffer is corrupted!\n");
return(1);
}
/* Run through the image */
for (y=0; y<yw; y++)
{
printf(".");
yoffset = y * xw;
for (x=0; x<=xw; x++)
{
offset = yoffset + x;
rr = *(rbu+offset);
gg = *(gbu+offset);
bb = *(bbu+offset);
*(rbu+offset) = 255 - rr; /* This is a color negative */
*(gbu+offset) = 255 - gg;
*(bbu+offset) = 255 - bb;
}
}
printf("\n");
return(0);
}